package com.itheima.controller;

import com.itheima.common.CommonResult;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import com.itheima.vo.SetmealByIdVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    @GetMapping("/list")
    public CommonResult list(String categoryId, Integer status) {

        List<Setmeal> setmeal = setmealService.getSetmealByIdStatus(categoryId, status);
        return CommonResult.success(setmeal);
    }

    @GetMapping("/dish/{id}")
    public CommonResult dish(@PathVariable String id) {
        SetmealByIdVo setmealById = setmealService.getMobileSetmealById(id);
        return CommonResult.success(setmealById);
    }


}
